package com.tch.dao;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.tch.bean.Book;

@Repository
public class Bookdaoimp implements Bookdao {
	@Autowired
	private SessionFactory sessionFactiory;

	private Session getSession() {
		return sessionFactiory.getCurrentSession();
	}

	public String findBookBybookname(){
		Query query = getSession().createQuery("select b.price from Book b where b.bookname = ?").setString(0, "ˮ�");
		return (String)query.uniqueResult();
	}
	
	public void bookPrice(int price) {
		System.out.println(price);
	}

	public void save(int num) {
		// TODO Auto-generated method stub
		Book b=new Book();
		b.setBookname("三国"+num);
		b.setPrice("111");
		this.getSession().save(b);
	}

}
